package cn.yibao.interviewtest.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

@ApiModel(value = "User",description = "用户类")
@Data
public class User extends Boss{

  @ApiModelProperty(value = "id",name = "用户ID")
  private long id;
  @ApiModelProperty(value = "username",name = "用户名")
  private String username;
  @ApiModelProperty(value = "password",name = "密码")
  private String password;
  @ApiModelProperty(value = "email",name = "邮箱")
  private String email;

  public User() {
    System.out.println("子类构造函数");
  }

  static{
    System.out.println("子类静态代码块");
  }

  {
    System.out.println("子类非静态代码块");
  }

  @Override
  public boolean equals(Object obj){
    if(this!=obj){
      return false;
    }
    if(obj==null){
      return false;
    }
    if(getClass()!=obj.getClass()){
      return false;
    }
    User user = (User)obj;
    if(id!=((User) obj).getId()||
    !username.equals(user.getUsername())||
            !password.equals(user.getPassword())||
                    !email.equals(user.getEmail())){
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    return Objects.hash(id,username,password,email);
  }

}

